#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define MAX_SIZE 10000
typedef int SetType[MAX_SIZE]; //use data=parent's label; use label=self data
void InsertNum(SetType S);
void InitData(SetType S, int n);
void Union(SetType S, int n1, int n2);
int Find(SetType S, int n);//return parent
void Check(SetType S);
int main()
{
    int Total_num;
    SetType S;
    char label = ' ';
    scanf("%d", &Total_num);
    InitData(S, Total_num);
    while (label != 'S')
    {
        scanf("%c", &label);
        switch (label)
        {
        case 'I':
            InsertNum(S);
            break;
        case 'C':
            Check(S);
            break;
        default:
            break;
        }

    } 
    int count;// count num components
    for (int i = 0; i < Total_num; i++)
    {
        if(S[i]<0)
            count++;
    }
    if(count == 1)
        printf("The network is connected.\n");
    else
        printf("There are %d components.\n", count);

    return 0;
}
void InitData(SetType S, int n)
{
    for (int i = 0; i < n;i++)
        S[i] = -1;
}
void InsertNum(SetType S)
{
    int c1, c2, Root1, Root2;
    scanf("%d %d\n", &c1, &c2);
    Root1 = Find(S, c1-1);
    Root2 = Find(S, c2-1);
    if(Root1 != Root2)
        Union(S, Root1, Root2);
}
int Find(SetType S, int n)
{
    if(S[n]<0)
        return n;
    else
        return S[n] = Find(S, S[n]);
}
void Union(SetType S,int n1, int n2)
{
    if (S[n1]<S[n2])
    {
        S[n1] += S[n2];
        S[n2] = n1;
    }
    else
    {
        S[n2] += S[n1];
        S[n1] = n2;
    }
    
}
void Check(SetType S)
{
    int c1, c2, Root1, Root2;
    scanf("%d %d\n", &c1, &c2);
    Root1 = Find(S, c1-1);
    Root2 = Find(S, c2-1);
    if(Root1 == Root2)
        printf("yes\n");
    else
        printf("no\n");
}